﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using System.Windows.Controls.Primitives;

namespace RestaurantWPF
{
    /// <summary>
    /// Interaction logic for NewOrder.xaml
    /// </summary>
    public partial class NewOrder : Window
    {
        private void ReadMenuItems(string path)
        {
            StreamReader reader = new StreamReader(path);
            using (reader)
            {
                string line = reader.ReadLine();
                while (line != null)
                {
                    var textBlock = new TextBlock();
                    textBlock.Text = line;
                    textBlock.MouseLeftButtonUp += (snd, args) =>
                        {
                            var newWin = new QuantityPrice();
                            newWin.Show();
                        };
                    this.MenuStackPanel.Children.Add(textBlock);
                    line = reader.ReadLine();
                }
            }
        }

        public NewOrder()
        {
            InitializeComponent();
            ReadMenuItems(@"..\..\salads.txt");
        }

        private void OnAddOrderItemClick(object sender, SelectionChangedEventArgs e)
        {
            //should add the item to the order and if it is a drink as new order to the bartender,
            //if it is a dish should be added to an order to the cook too
            // Possible options for the combobox:
            //Salads
            //Main dishes
            //Desserts
        }

        private void OnAddOrderItemClick(object sender, MouseButtonEventArgs e)
        {
            //to be implemented
        }

        private void OnChooseSaladClick(object sender, RoutedEventArgs e)
        {
            this.MenuStackPanel.Children.Clear();
            ReadMenuItems(@"..\..\salads.txt");
        }

        private void OnChooseDishClick(object sender, RoutedEventArgs e)
        {
            this.MenuStackPanel.Children.Clear();
            ReadMenuItems(@"..\..\dishes.txt");
        }

        private void OnChooseDrinkClick(object sender, RoutedEventArgs e)
        {
            this.MenuStackPanel.Children.Clear();
            ReadMenuItems(@"..\..\drinks.txt");
        }

    }
}
